package utils

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"os"
)

func ParseJsonFile(jsonPath string, v interface{}) {
	RootPath, wdErr := os.Getwd()
	if wdErr != nil {
		panic(wdErr)
	}

	configPath := fmt.Sprintf("%s/%s", RootPath, jsonPath)
	jsonString, openErr := os.Open(configPath)
	if openErr != nil {
		panic(openErr)
	}

	jsonData, readErr := ioutil.ReadAll(jsonString)
	if readErr != nil {
		panic(readErr)
	}

	decodeErr := json.Unmarshal(jsonData, &v)
	if decodeErr != nil {
		panic(decodeErr)
	}
}
